<!DOCTYPE html>
<!--suppress ALL-->
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui/css/H-ui.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/H-ui.admin.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/Hui-iconfont/1.0.8/iconfont.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/skin/default/skin.css}" id="skin"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/h-ui.admin/css/style.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/laypage/1.2/skin/laypage.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/static/lib/laypage/1.2/skin/laypage.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/static/css/iconfont.css}">
    <script type="text/javascript" th:src="@{/static/lib/jquery/1.9.1/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/layer/2.4/layer.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui/js/H-ui.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/h-ui.admin/js/H-ui.admin.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
    <script type="text/javascript" th:src="@{/static/lib/datatables/1.10.0/jquery.dataTables.min.js}"></script>
    <script type="text/javascript" th:src="@{/static/js/laypage/laypage.js}"></script>
    <script th:src="@{/static/lib/vue.min.js}"></script>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 资讯管理 <span
        class="c-gray en">&gt;</span> 资讯列表 <a class="btn btn-success radius r"
                                              style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <a id="aa" href="/course/toAddCourse" class="btn btn-success"><span class="iconfont">&#xe614;</span> 添加课程</a>
        <span class="r">共有数据：<strong id="countCol"></strong> 条</span></div>
    <div class="mt-20" id="list">
        <table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
            <thead>
            <tr class="text-c">
                <th width="80">编号</th>
                <th width="120">课程标题</th>
                <th width="120">一级分类</th>
                <th width="80">二级分类</th>
                <th width="80">发布人</th>
                <th width="80">价格</th>
                <th width="80">课程介绍</th>
                <th width="80">发布时间</th>
                <th width="80">课程封面</th>
                <th width="80">状态</th>
                <th width="80">删除</th>
            </tr>
            </thead>
            <tbody>
            <tr class="text-c" v-for="(item,index) in result">
                <td>{{index+1}}</td>
                <td>{{item.courseName}}</td>
                <td>{{item.type.typeName}}</td>
                <td>{{item.subject.subjectName}}</td>
                <td>{{item.teacher.teacherName}}</td>
                <td>{{item.coursePrice}}</td>
                <td>{{item.courseIntroduction}}</td>
                <td>{{item.courseTime}}</td>
                <td><img :src="item.courseCover" width="50px" height="80px"></td>
                <td>{{item.courseFlag}}</td>
                <td><a title="删除" href="javascript:;" @click="admin_del(item.courseId)" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
            </tr>
            </tbody>
        </table><br/>
        <div id="pagenav"></div>
    </div>
</div>

</body>

<script th:inline="javascript">

    /*管理员-删除*/
    function admin_del(id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '/course/delCourseById',
                data:{
                    courseId:id
                }
                ,dataType: 'json',
                success: function(data){
                    if (data[0] == "succ"){
                        layer.msg('已删除!',{icon:1,time:1000});
                        window.location.reload();
                    }

                }
            });
        });
    }

    var app = new Vue({
        el: '#list',
        data: {
            result: []
        }
    });

    var getAllCourse = function (curr) {
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: '/course/queryCourseByTid',
            data: {
                pageSize: 3,
                pageNum: curr || 1,
                teacherId:[[${session.teacher.teacherId}]]
            },
            success: function (data) {
                app.result = data.page.list;
                $("#countCol").html(data.page.total);
                laypage({
                    cont: 'pagenav',
                    skin: '#4169E1',
                    pages: data.totalPage,
                    first: '首页',
                    last: '尾页',
                    curr: curr || 1,
                    jump: function (obj, first) {
                        if (!first) {
                            getAllCourse(obj.curr);
                        }
                    }
                })
            }
        })
    };
    getAllCourse();

    /*搜索按钮*/
    $("#aa").click(function () {
        getAllCourse()
    })

    /*课程审核（同意）*/
    var succ = function (id) {
        $.ajax({
            url: "/admin/courseAgree",
            type: 'post',
            dataType: 'json',
            data: {
                courseId: id
            },
            success: function (data) {
                location.replace(location.href)
            }
        })
    }
    /*课程审核（拒绝）*/
    var refuse = function (id) {
        $.ajax({
            url: "/admin/courseRefuse",
            type: 'post',
            dataType: 'json',
            data: {
                courseId: id
            },
            success: function (data) {
                location.replace(location.href)
            }
        })
    }

    /*查看详情*/
    var queryById = function (id) {
        location.href = "/admin/toList?courseId=" + id
    }

</script>
</html>
